<template>
	<view class="content bgc-f0 p26">
		<template v-if="business.length > 0">
			<template v-for="item in business">
				<view :key="item.id" class="_list br12 bgc-fff z-flex mb26" @click="handViewShopInfo(item.id)">
					<u-image :src="item.img[0]" width="170" height="150"></u-image>
					<view class="z-flex z-flex-around ml20" style="flex-direction: column;">
						<view><text class="fwb c-333">{{item.name}}</text></view>
						<view><text class="fs26 c-666">{{item.address}}</text></view>
					</view>
				</view>
			</template>
		</template>
		<vempty v-if="datalen" title="暂无数据"></vempty>
	</view>
</template>

<script>
	import {
		businessListApi
	} from '@/api/shop.js'
	export default {
		data() {
			return {
				query: {
					page: 1,
					size: 99999
				},
				datalen: false,
				option: {},
				business: []
			}
		},
		onLoad(option) {
			if(option){
				this.option = option
			}
		},
		onShow() {
			this.$nextTick(this.getBusinessList)
		},
		onPullDownRefresh() {
			this.init()
			this.getBusinessList()
		},
		methods: {
			async getBusinessList(){
				uni.showLoading({title: '加载中'})
				const {code,data} = await businessListApi({...this.query})
				uni.hideLoading()
				this.business = data.list
				this.datalen = data.list.length == 0
				uni.stopPullDownRefresh()
			},
			handViewShopInfo(id){
				uni.$u.route({
					type: 'navigateTo',
					url: 'mapPages/store_details/index',
					params: {
						id
					}
				})
			},
			init(){
				this.query.page = 1
				this.query.size = 99999
			}
		}
	}
</script>

<style scoped lang="scss">
	.content {
	}
</style>
